package cn.iocoder.yudao.module.course.dal.mysql.material;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.course.dal.dataobject.material.MaterialDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.course.controller.admin.material.vo.*;

/**
 * 知识库-素材 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MaterialMapper extends BaseMapperX<MaterialDO> {

    default PageResult<MaterialDO> selectPage(MaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialDO>()
                .likeIfPresent(MaterialDO::getName, reqVO.getName())
                .eqIfPresent(MaterialDO::getMaterialType, reqVO.getMaterialType())
                .eqIfPresent(MaterialDO::getParentId, reqVO.getParentId())
                .eqIfPresent(MaterialDO::getSize, reqVO.getSize())
                .eqIfPresent(MaterialDO::getMaterialUrl, reqVO.getMaterialUrl())
                .eqIfPresent(MaterialDO::getViewUrl, reqVO.getViewUrl())
                .eqIfPresent(MaterialDO::getWorkStatus, reqVO.getWorkStatus())
                .eqIfPresent(MaterialDO::getWorkErrorInfo, reqVO.getWorkErrorInfo())
                .eqIfPresent(MaterialDO::getVersion, reqVO.getVersion())
                .eqIfPresent(MaterialDO::getDeptId, reqVO.getDeptId())
                .betweenIfPresent(MaterialDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(MaterialDO::getDescription, reqVO.getDescription())
                .eqIfPresent(MaterialDO::getVideoDuration, reqVO.getVideoDuration())
                .orderByDesc(MaterialDO::getId));
    }

}